<template>
	<view class="box">
		<view class="top" @click="tiaoguo()" :style="'top:'+(statusBarHeight1+10)+'px'">
			<span>跳过</span>
			<span>{{text}}</span>
		</view>
		<image @click="guangLi()" class="guangG_9" :src="openScreenData.enclosure" mode="aspectFill"></image>
	</view>
</template>

<script>
	import {
	  mapGetters
	} from "vuex";
	export default {
		data() {
			return {
				text:5,
				time:'',
				openScreenData:{}
			}
		},
	    async onLoad() {
			await this.openScreenAdvertis()
			this.setTime()
		},
		computed: {
		  ...mapGetters(["statusBarHeight1", "userinfo"])
		},
		methods:{
			// 获取开屏广告数据
			async openScreenAdvertis(){
				await this.$myRequest.get("/api/mobile/public/getOpenScreenAdvertising").then((res) => {
					this.openScreenData = res.commonOpenScreenAdvertising[0]
				});
			},
			setTime(){
				let that=this
				this.time=setInterval(()=>{
					that.text =that.text - 1
					if(that.text==0){
						uni.switchTab({
							url:'/pages/index/index'
						})
						clearInterval(this.time)
					}
				},1000)
			},
			tiaoguo(){
				clearInterval(this.time)
				uni.switchTab({
					url:'/pages/index/index'
				})
			},
			guangLi(){
				clearInterval(this.time)
				console.log(this.openScreenData,'dsda')
				if(this.openScreenData.jumpPosition == '1'){
					uni.redirectTo({
						url: this.openScreenData.jumpLink
					})
				}else{
					// 跳转外部链接
					plus.runtime.openURL(this.openScreenData.jumpLink)
					uni.switchTab({
						url:'/pages/index/index'
					})
				}
			}
		}
	}
</script>

<style lang="scss">
	.box{
		width: 100%;
		height: 100vh;
		overflow: hidden;
		.top{
			position: fixed;
			right: 40rpx;
			width: 140rpx;
			height: 60rpx;
			border-radius: 40rpx;
			background-color: rgba(0, 0, 0, 0.2);
			color: #FFF;
			display: flex;
			align-items: center;
			justify-content: space-evenly;
			z-index: 999;
		}
		.guangG_9{
			display: block;
			width: 100%;
			height: 100%;
		}
	}
</style>